package ltd.dujiabao.capability.domain.rulemng;

import java.util.Collections;
import java.util.List;

import ltd.dujiabao.capability.domain.capmng.cap.Capability;

/**
 * @author : DuJiabao
 * @Project : ddd-capability
 * @Time : 2024/4/13 12:22
 * @Desc :
 */
public class Rule {

    private final String funcName;

    private final List<VersionRule> versionRules;

    public Rule(String funcName, List<VersionRule> versionRules) {
        this.funcName = funcName;
        this.versionRules = Collections.unmodifiableList(versionRules);
    }

    public String getFuncName() {
        return funcName;
    }

    public List<VersionRule> getVersionRules() {
        return versionRules;
    }

    public boolean checkIfSupport(Capability capability) {
        return versionRules.stream()
                .anyMatch(versionRule -> versionRule.checkIfSupport(capability));
    }
}
